/**
 * 
 */
package com.base.myproject.client.busi.b2c;

import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.VerticalPanel;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.extjs.gxt.ui.client.widget.layout.TableData;
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.InlineHyperlink;
import com.google.gwt.user.client.ui.Widget;

/**
 * 多页显示的产品，通常此页会放多个这种产品
 * @author zgw
 *2009-7-16 下午12:55:49
 * javazgw@gmail.com
 */
public class OneProductMin extends ContentPanel{
	ProdectDesc prodectdesc =null;
	public OneProductMin(ProdectDesc prodectdesc )
	{
		this.prodectdesc =prodectdesc;
		init();
	}

	void init()
	{
		TableLayout tl = new TableLayout(2);
		TableData td = new TableData();
		td.setRowspan(1);
		td.setColspan(1);
		
		RowLayout cl = new RowLayout();
		setLayout(cl);
		this.setHeaderVisible(false);
		this.setBodyBorder(false);
		add(CreateImage());
		add(Createb2cgcodeDesc());
	
	}
	LayoutContainer CreateImage()
	{
		LayoutContainer imagecontainer = new LayoutContainer();
		InlineHyperlink hl ;
		if(getProdectdesc().getMainimagepath()!=null)
		 hl = new InlineHyperlink("<img src='"+getProdectdesc().getMainimagepath()+"' width='100' height='100' />",true,"");
		else
			 hl = new InlineHyperlink("<img src='' width='100' height='100' />",true,"");
		hl.addClickListener(new ClickListener(){

			@Override
			public void onClick(Widget sender) {
				// TODO Auto-generated method stubb
				System.out.println("----"+getProdectdesc().getId());
				MainPage.getCenterpanel().removeAll();
				MainPage.getCenterpanel().add(new OneProduct(getProdectdesc()));
				MainPage.getCenterpanel().layout();
			}
			
		});
		final Image image = new Image();
		
		image.setUrl("<a href='#'>busiimages/20090714/1247575528765Winter.jpg</a>");
		
		image.setSize("100%", "100%");
		imagecontainer.add(hl);
		//imagecontainer.add(image);
		imagecontainer.setWidth(100);
		imagecontainer.setHeight(100);
		imagecontainer.setStyleAttribute("class", "thumb-wrap");
		//imagecontainer.sinkEvents(Event.ONCLICK);
		image.addClickHandler(new ClickHandler(){

			@Override
			public void onClick(ClickEvent event) {
				// TODO Auto-generated method stub
				System.out.println("--"+image.getElement().getInnerHTML());
				
			//	image.getElement().getInnerHTML();
			}
			
		});
		DOM.setElementProperty(imagecontainer.getElement(), "href", "#" + "");
//		imagecontainer.getElement().setPropertyString("href", "#" + "");

		return imagecontainer;
	}
	
	LayoutContainer Createb2cgcodeDesc()
	{
		LayoutContainer desc = new LayoutContainer();
		VerticalPanel vpanel = new VerticalPanel();
		vpanel.setWidth(200);
		Html html = new Html();
		html.setHtml("<a>价格------------------------------------------------------------------------------------------------------------");
		vpanel.add(html);
		
		
		vpanel.setStyleAttribute("margin", "20px");
		desc.add(vpanel);
	
	
		return desc;
		
	}

	
	public ProdectDesc getProdectdesc() {
		return prodectdesc;
	}

	public void setProdectdesc(ProdectDesc prodectdesc) {
		this.prodectdesc = prodectdesc;
	}
	
	
}
